import { userprofilesapi } from "@/request/api";
export default {
    namespaced: true,
    state: {
        cartTotal: 1,
        userinfo: {
            nickName: '未登录',
            coin: 0,
            headImg: require('@/assets/img/monad.png')
        }
    },
    mutations: {
        chanuserinfo(state, payload) {
            state.userinfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        inituserinfo(state) {
            state.cartTotal= 1,
            state.userinfo={
                nickName: '未登录',
                coin: 0,
                headImg: require('@/assets/img/monad.png')
            }
        }
    },
    actions: {
        async asyncchanuserinfo({ commit }) {
            let res = await userprofilesapi();
            // console.log('userinfo',res.data);
            // if(res.data){
            commit('chanuserinfo', res.data)
            // }
        }
    },
}